package com.hdoit.kylin.logical.money.service.impl;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.tennetcn.common.dao.base.impl.SuperService;
import com.tennetcn.common.message.DaoBaseException;
import com.tennetcn.common.message.PagerModel;
import com.hdoit.kylin.logical.money.dao.IReimbursementDao;
import com.hdoit.kylin.logical.money.model.Reimbursement;
import com.hdoit.kylin.logical.money.service.IReimbursementService;
import com.hdoit.kylin.logical.viewmodel.money.ReimbursementSearch;
import com.hdoit.kylin.selfcommon.enums.RoleMapper;
/**
* @author luozhicheng
* @email
* @createtime 2017年07月18日 19:49:00
* @comment
*/
@Component
public class ReimbursementServiceImpl extends SuperService<Reimbursement> implements IReimbursementService{
	
	private IReimbursementDao moneyDao;
	
	
	public IReimbursementDao getMoneyDao() {
		return moneyDao;
	}
	
	@Resource
	public void setMoneyDao(IReimbursementDao moneyDao) {
		this.moneyDao = moneyDao;
	}

	@Override
	public List<Reimbursement> queryList(ReimbursementSearch search,PagerModel pagerModel) {
		if(RoleMapper.undergraduate.equals(search.getUserType()))
			return moneyDao.queryStudentList(search,pagerModel);
		else if(RoleMapper.teacher.equals(search.getUserType()))
			return moneyDao.queryTeacherList(search,pagerModel);
		else if(RoleMapper.manager.equals(search.getUserType())||RoleMapper.operation.equals(search.getUserType())){
			List<Reimbursement> allMoneyList=moneyDao.queryStudentList(search,pagerModel);
			allMoneyList.addAll(moneyDao.queryTeacherList(search,pagerModel));
			return allMoneyList;
		}
		return null;
			
	}

	@Override
	public List<Reimbursement> queryListByProjectId(ReimbursementSearch search,PagerModel pagerModel) {
		return queryList(search,pagerModel);
	}

	@Override
	public int queryCount(ReimbursementSearch search) {
		if(RoleMapper.undergraduate.equals(search.getUserType())||RoleMapper.postgraduate.equals(search.getUserType())
				||RoleMapper.doctor.equals(search.getUserType()))
			return moneyDao.queryStudentCount(search);
		if(RoleMapper.teacher.equals(search.getUserType()))
			return moneyDao.queryTeacherCount(search);
		if(RoleMapper.manager.equals(search.getUserType())||RoleMapper.operation.equals(search.getUserType())){
			try {
				return moneyDao.queryCount();
			} catch (DaoBaseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return 0;
		
	}


}